import { observable, action } from 'mobx';
import http from '../common/http';
import paramInspect from '../common/paramInspect';

class UserStore {
  constructor(rootStore) {
    this.rootStore = rootStore
  }

  @observable userParam = {
    "pageIndex": 1,
    "pageSize": 10,
    "delState": false
  }
  @observable userList = [];
  @observable userTotal = 0;
  @observable userLoadSuccess = false;

  @action toGetUserList = () => {
    this.rootStore.globalStore.toShowLoding();
    http.get('/member/list', paramInspect(this.userParam))
    .then((response) => {
      this.rootStore.globalStore.toHideLoading();
      if (response.success) {
        this.userLoadSuccess = true;
        this.userList = response.data.dataList;
        this.userTotal = response.data.total;
      }
    })
  }

  @action toChangePageNumber = (pageNumber) => {
    this.userParam.pageIndex = pageNumber;
    this.toGetUserList();
  }

  @action toChangePageSize = (pageSize) => {
    this.userParam.pageIndex = 1;
    this.userParam.pageSize = pageSize;
    this.toGetUserList();
  }

  @action filterParamSearch = (param) => {
    this.userParam.accountNo = param.accountNo;
    this.userParam.mobile = param.mobile;
    this.userParam.pageIndex = 1;
    this.toGetUserList();
  }

}


export default UserStore;
